package net.awpspace.mobile;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import net.awpspace.mobile.form.MainForm;
import net.awpspace.mobile.global.Global;

import com.nokia.mid.ui.CategoryBar;
import com.sun.lwuit.Display;

/**
 * MIDlet main entry point
 * 
 * @author Diep
 * 
 */
public class Application extends MIDlet {

	private CategoryBar categoryBar;

	/**
	 * Init LWUIT first
	 */
	public Application() {
		Display.init(this);
		Global.isLocal = true;
	}

	/**
	 * Modify current category bar
	 * 
	 * @param bar
	 * @param visible
	 */
	public void setCategoryBar(CategoryBar bar, boolean visible) {
		if (bar == null) {
			if (categoryBar != null) {
				categoryBar.setVisibility(false);
			}
			categoryBar = null;
		} else {
			categoryBar = bar;
			categoryBar.setVisibility(visible);
		}
	}

	/**
	 * Application start point
	 */
	protected void startApp() throws MIDletStateChangeException {
		new MainForm(this, null).show();
	}

	protected void destroyApp(boolean unconditional)
			throws MIDletStateChangeException {
	}

	protected void pauseApp() {
	}
}
